package com.example.shiwuyouproject.ui.fragment.my.activity.viewmodel

import androidx.lifecycle.MutableLiveData
import com.example.shiwuyouproject.base.BaseViewModel
import com.example.shiwuyouproject.ui.fragment.my.activity.bean.CommissionTotalBean
import com.example.shiwuyouproject.ui.fragment.my.activity.bean.GetUserShareDataBean
import com.example.shiwuyouproject.ui.my.bean.MyIncomeBean
import retrofit2.http.Field

class MyIncomeViewModel : BaseViewModel() {
    private val getRealNameAuthenticatioApi by lazy { RetrofitClient.getApiService() }
    val getCommissionTotalResult = MutableLiveData<CommissionTotalBean>()

    /**
     * 收益统计
     */
    fun getCommissionTotal(create_year: String, create_month: String) {
        launch(
            block = {
                val codeStatus =
                    getRealNameAuthenticatioApi.getCommissionTotal(create_year, create_month)
                if (codeStatus.success()) {
                    getCommissionTotalResult.value = codeStatus.result()
                } else {
                    messageStatus.value = codeStatus.message()
                }
            },
            error = {
                messageStatus.value = "网络错误"
            },
            cancel = {
                messageStatus.value = "网络错误"
            },
            showErrorToast = false
        )
    }

    val PostCommissionListsResult = MutableLiveData<MyIncomeBean>()

    /**
     * 我的收益
     *
     */
    fun PostCommissionLists(
        page: String,
        create_year: String,
        create_month: String
    ) {
        launch(
            block = {
                val codeStatus =
                    getRealNameAuthenticatioApi.PostCommissionLists(page, create_year, create_month)
                PostCommissionListsResult.value = codeStatus.result()
            },
            error = {

            },
            cancel = {

            },
            showErrorToast = false
        )

    }


    val getUserShareDataResult = MutableLiveData<GetUserShareDataBean>()

    /**
     * 我的分享
     *
     */
    fun getUserShareData() {
        launch(
                block = {
                    val codeStatus =
                            getRealNameAuthenticatioApi.getUserShareData()
                    getUserShareDataResult.value = codeStatus.result()
                },
                error = {

                },
                cancel = {

                },
                showErrorToast = false
        )

    }
}